home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11706 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.0 KB  |  56 lines

  1. Path: badger.wmin.ac.uk!darec
  2. From: darec@westminster.ac.uk (Nadarajah Thavaneethan)
  3. Newsgroups: comp.lang.c
  4. Subject: Please help me
  5. Date: 25 Mar 1996 18:15:17 GMT
  6. Organization: University of Westminster
  7. Message-ID: <4j6nrl$lfk@badger.wmin.ac.uk>
  8. NNTP-Posting-Host: badger.wmin.ac.uk
  9. X-Newsreader: TIN [version 1.2 PL2]
  10.  
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #define  SIZE 60
  14.  
  15.  
  16. void main(void)
  17. {
  18.  
  19.         char c[SIZE];
  20. int index, next;
  21.  
  22.  
  23.     for (index=0; index(SIZE && ( c[index] = getchar() != '\n'); index++);
  24.      c[index] = 0;
  25.          for(; index > 0; index--)
  26.             for (next = 0; next < index; next++)
  27.                compchar(c[next-1],c[next]);
  28.  
  29.  
  30.             printf("\n the line is now %s\n",c);
  31.  }
  32.  
  33.  void compchar (char c1, char c2)
  34.  {
  35.  
  36.  char p;
  37.  
  38.  
  39.           if (c1 > c2)
  40.               p = c1;
  41.               c1 = c2;
  42.               c2 = p;
  43.  }
  44.  
  45.  
  46. This program reads a line of data and sorts it into ascending ASCII sequence
  47.  it doesn't but it should.
  48.  
  49. Please mail me.
  50.  
  51. darec@westminster.ac.uk
  52.  
  53. Thanks in advance..
  54.  
  55.  
  56.